package com.lindroy.androidplayer.logic.model

import com.lindroy.androidplayer.R
import com.lindroy.androidplayer.extensions.no
import com.lindroy.androidplayer.extensions.yes

/**
 * @author Lin
 * @date 2021/4/6
 * @function 文章实体类
 */
data class ArticleResp(
    val apkLink: String = "",
    val audit: Int = 0,
    val author: String = "",
    val canEdit: Boolean = false,
    val chapterId: Int = 0,
    val chapterName: String = "",
    var collect: Boolean = false,
    val courseId: Int = 0,
    val desc: String = "",
    val descMd: String = "",
    val envelopePic: String = "",
    val fresh: Boolean = false,
    val host: String = "",
    val id: Int = 0,
    val link: String = "",
    val niceDate: String = "",
    val niceShareDate: String = "",
    val origin: String = "",
    val prefix: String = "",
    val projectLink: String = "",
    val publishTime: Long = 0,
    val realSuperChapterId: Int = 0,
    val selfVisible: Int = 0,
    val shareDate: Long = 0,
    val shareUser: String = "",
    val superChapterId: Int = 0,
    val superChapterName: String = "",
    val tags: List<Tag> = listOf(),
    val title: String = "",
    val type: Int = 0,
    val userId: Int = 0,
    val visible: Int = 0,
    val zan: Int = 0,
) {
    //是否为置顶文章，默认为否
    val isTop: Boolean
        get() = type == 1 //type为1是置顶文章

    data class Tag(
        val name: String = "",
        val url: String = ""
    )

    val collectIconId: Int
        get() = collect.yes { R.drawable.ic_collection_selected }
            .no { R.drawable.ic_collection_unselected }
}

/*
{
    "apkLink": "",
    "audit": 1,
    "author": "鸿洋",
    "canEdit": false,
    "chapterId": 360,
    "chapterName": "小编发布",
    "collect": false,
    "courseId": 13,
    "desc": "",
    "descMd": "",
    "envelopePic": "",
    "fresh": false,
    "host": "",
    "id": 17675,
    "link": "https://wanandroid.com/blog/show/2964",
    "niceDate": "2021-03-18 13:26",
    "niceShareDate": "2021-03-18 13:26",
    "origin": "",
    "prefix": "",
    "projectLink": "",
    "publishTime": 1616045214000,
    "realSuperChapterId": 297,
    "selfVisible": 0,
    "shareDate": 1616045193000,
    "shareUser": "",
    "superChapterId": 298,
    "superChapterName": "原创文章",
    "tags": [
    {
        "name": "本站发布",
        "url": "/article/list/0?cid=360"
    }
    ],
    "title": "公告：wanandroid api 对于毕设的回复",
    "type": 1,
    "userId": -1,
    "visible": 1,
    "zan": 0
}
*/

